import React from 'react'
import {bindActionCreators} from'redux'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import SendText from '../components/SendText'
import ChatDisplay from '../components/ChatDisplay'
import * as TodoActions from '../actions';
import { withRouter } from "react-router-dom"
import  AnonymousBar  from '../components/AnonymousBar';  
const AnonymousChat = ({anonymousChat,actions}) => (
<div>
    <AnonymousBar/>
    <ChatDisplay chatState = {anonymousChat}/>
    <SendText sendMessage = {actions.sendMessage} chatState = {anonymousChat}/>
</div>
) 

AnonymousChat.propTypes = {
    anonymousChat:PropTypes.object.isRequired,
    actions:PropTypes.object.isRequired,
}

const mapStateToProps = state =>({
    anonymousChat:state.anonymousChat
})

const mapDispatchToProps = dispatch =>({
  actions:bindActionCreators(TodoActions,dispatch)
})


export default connect(mapStateToProps,mapDispatchToProps)(withRouter(AnonymousChat))
